﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Hosting;

namespace Vms.Web.Lib
{
    public class Utility
    {
        public static string PathLibContentImg = HostingEnvironment.MapPath("~/Areas/Lib/Lib_Data/Imgs/");
        public static string pathScreenStatus = HostingEnvironment.MapPath("~/App_Data/ScreenStatus/");
        public static string PathScreenContentTxt = HostingEnvironment.MapPath("~/App_Data/Txts/");
        public static string PathScreenContentImg = HostingEnvironment.MapPath("~/App_Data/Imgs/");
        public static string pathLibContentTxt = HostingEnvironment.MapPath("~/Areas/Lib/Lib_Data/Txts/");

        #region CONTROLLER_TYPE

        public static object[,] ControlerType = new object[,] { 
                                                                {"BX-3A", BXIV.CONTROLLER_TYPE_3A},
                                                                {"BX-3A1", BXIV.CONTROLLER_TYPE_3A1},
                                                                {"BX-3A2", BXIV.CONTROLLER_TYPE_3A2},
                                                                {"BX-3M", BXIV.CONTROLLER_TYPE_3M},
                                                                {"BX-3T", BXIV.CONTROLLER_TYPE_3T},
                                                               
                                                                {"BX-4A", BXIV.CONTROLLER_TYPE_4A},
                                                                {"BX-4A1", BXIV.CONTROLLER_TYPE_4A1},
                                                                {"BX-4A2", BXIV.CONTROLLER_TYPE_4A2},
                                                                {"BX-4A3", BXIV.CONTROLLER_TYPE_4A3},
                                                                {"BX-4AQ", BXIV.CONTROLLER_TYPE_4AQ},

                                                                {"BX-4U0", BXIV.CONTROLLER_TYPE_4U0},
                                                                {"BX-4U1", BXIV.CONTROLLER_TYPE_4U1},
                                                                {"BX-4U2", BXIV.CONTROLLER_TYPE_4U2},
                                                                {"BX-4U2X", BXIV.CONTROLLER_TYPE_4U2X},
                                                                {"BX-4U3", BXIV.CONTROLLER_TYPE_4U3},
                                                                {"BX-4UT", BXIV.CONTROLLER_TYPE_4UT},

                                                                {"BX-4C", BXIV.CONTROLLER_TYPE_4C},
                                                                {"BX-4E", BXIV.CONTROLLER_TYPE_4E},
                                                                {"BX-4E1", BXIV.CONTROLLER_TYPE_4E1},
                                                                {"BX-4EL", BXIV.CONTROLLER_TYPE_4EL},

                                                                {"BX-4M0", BXIV.CONTROLLER_TYPE_4M0},
                                                                {"BX-4M", BXIV.CONTROLLER_TYPE_4M},
                                                                {"BX-4M1", BXIV.CONTROLLER_TYPE_4M1},
                                                                {"BX-4MC", BXIV.CONTROLLER_TYPE_4MC},

                                                                {"BX-5A0", BXIV.CONTROLLER_TYPE_5A0},
                                                                {"BX-5A1", BXIV.CONTROLLER_TYPE_5A1},
                                                                {"BX-5A1-Wifi", BXIV.CONTROLLER_TYPE_5A1WIFI},
                                                                {"BX-5A2", BXIV.CONTROLLER_TYPE_5A2},
                                                                {"BX-5A2-RF", BXIV.CONTROLLER_TYPE_5A2RF},
                                                                {"BX-5A2-Wifi", BXIV.CONTROLLER_TYPE_5A2WIFI},
                                                                {"BX-5A3", BXIV.CONTROLLER_TYPE_5A3},
                                                                {"BX-5A4", BXIV.CONTROLLER_TYPE_5A4},
                                                                {"BX-5A4-RF", BXIV.CONTROLLER_TYPE_5A4RF},
                                                                {"BX-5A4-Wifi", BXIV.CONTROLLER_TYPE_5A4WIFI},
                                                                {"BX-5AT", BXIV.CONTROLLER_TYPE_5AT},

                                                                {"BX-5E2", BXIV.CONTROLLER_TYPE_5E2},
                                                                {"BX-5E3", BXIV.CONTROLLER_TYPE_5E3},

                                                                {"BX-5M1", BXIV.CONTROLLER_TYPE_5M1},
                                                                {"BX-5M2", BXIV.CONTROLLER_TYPE_5M2},
                                                                {"BX-5M3", BXIV.CONTROLLER_TYPE_5M3},
                                                                {"BX-5M4", BXIV.CONTROLLER_TYPE_5M4},

                                                                {"BX-5UT", BXIV.CONTROLLER_TYPE_5UT},
                                                                {"BX-5U0", BXIV.CONTROLLER_TYPE_5U0},
                                                                {"BX-5U1", BXIV.CONTROLLER_TYPE_5U1},
                                                                {"BX-5U2", BXIV.CONTROLLER_TYPE_5U2},
                                                                {"BX-5U3", BXIV.CONTROLLER_TYPE_5U3},
                                                                {"BX-5U4", BXIV.CONTROLLER_TYPE_5U4},
                                                            };

        /// <summary>
        /// Get value of controller type
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static int GetControllerTypeValueByName(string name)
        {
            int n = ControlerType.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (name.Equals(ControlerType[i, 0]))
                {
                    return (int)ControlerType[i, 1];
                }
            }
            return (int)ControlerType[0, 1];
        }

        /// <summary>
        /// Get name of value of controller type
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetControllerTypeNameByValue(int value)
        {
            int n = ControlerType.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (value == (int)ControlerType[i, 1])
                {
                    return (string)ControlerType[i, 0];
                }
            }
            return (string)ControlerType[0, 0];
        }
        #endregion

        #region DISPLAY_MODE

        public static object[,] DisplayMode = new object[,]
                            {
                                {"Bubbling", BXIV.DISPLAY_MODE_BUBBLING},
                                {"Continue Move Down", BXIV.DISPLAY_MODE_CONTINUEMOVEDOWN}
                            };

        /// <summary>
        /// Get value display mode.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int DisplayModeValueOfName(string name)
        {
            int n = DisplayMode.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (name.Equals(DisplayMode[i, 0]))
                {
                    return (int)DisplayMode[i, 1];
                }
            }
            return (int)ControlerType[0, 1];
        }

        /// <summary>
        /// Get name display mode.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string DisplayModeNameOfValue(int value)
        {
            int n = DisplayMode.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (value == int.Parse(""+DisplayMode[i, 1]))
                {
                    return (string)DisplayMode[i, 0];
                }
            }
            return (string)ControlerType[0, 0];
        }

        #endregion

        #region OTHER_METHODS

        /// <summary>
        /// Convert hour and minute to string
        /// </summary>
        /// <param name="hour"></param>
        /// <param name="minute"></param>
        /// <returns></returns>
        public static string TimeToString(int hour, int minute)
        {
            string time = "";
            time += (hour < 10) ? "0" + hour + ":" : hour + ":";
            time += (minute < 10) ? "0" + minute : minute + "";
            return time;
        }

        #endregion

        #region ADJUST_TYPE

        public static object[,] ADJUST_TYPE = new object[,] { {"Manually", 0}, {"Automatically", 1}};

        public static int GetAdjustValueByName(string name)
        {
            return ("Manually".Equals(name)) ? int.Parse(""+ADJUST_TYPE[0, 1]) : int.Parse(""+ADJUST_TYPE[1, 1]);
        }

        public static string GetAdjustNameByValue(int value)
        {
            return (value == 0) ? ("" + ADJUST_TYPE[0, 0]) : ("" + ADJUST_TYPE[1, 0]);
        }

        #endregion

        #region FONT_COLOR
        //, {"Blue", 4}, {"Mauve", 5}, {"LightGreen", 6}, {"White", 7}
        public static object[,] FONT_COLOR = new object[,] { { "Red", 1 }, { "Green", 2 }, { "Yellow", 3 }, { "Blue", 4 }, { "White", 7 } };

        public static int GetFontColorValueByName(string name)
        {
            int n = FONT_COLOR.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (name.Equals(FONT_COLOR[i, 0]))
                {
                    return (int)FONT_COLOR[i, 1];
                }
            }
            return (int)ControlerType[0, 1];
        }

        public static string GetFontColorNameByValue(int value)
        {
            int n = FONT_COLOR.GetLength(0);
            for (int i = 0; i < n; ++i)
            {
                if (value == (int)FONT_COLOR[i, 1])
                {
                    return (string)FONT_COLOR[i, 0];
                }
            }
            return (string)FONT_COLOR[0, 0];
        }

        #endregion

        #region FONT_NAME

        public static string[] FONT_NAME = new string[] { "Tahoma", "Arial", "Times New Roman"};

        #endregion

        #region DISPLAY_MODE

        public static object[,] DISPLAY_MODE = new object[,] { 
            {"Random", BXIV.DISPLAY_MODE_RANDOM}, {"Static", BXIV.DISPLAY_MODE_STATIC},
            {"Derect Show", BXIV.DISPLAY_MODE_DIRECTSHOW}, {"Move Left", BXIV.DISPLAY_MODE_MOVELEFT}
        };

        #endregion

      
    }

        
}